/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package htmlparsetest;

import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.cyberneko.html.parsers.DOMParser;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

/**
 *
 * @author Swang
 */
public class HtmlParseTest {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        try {
            String projectPath = System.getProperty("user.dir");
            DOMParser parser = new DOMParser();
            String testFilePath = projectPath + File.separator + "test.html";
            System.out.println("testFilePath: " + testFilePath);
            parser.parse(testFilePath);
            NodeList nodes = parser.getDocument().getElementsByTagName("div");
            for (int i = 0; i < nodes.getLength(); i++) {
                Node node = nodes.item(i);
                System.out.println(node.getTextContent()); //Hello,Neko Html
            }
        } catch (SAXException ex) {
            Logger.getLogger(HtmlParseTest.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(HtmlParseTest.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
